<?php

namespace App\Admin\Actions\Coupon;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class Allot extends RowAction
{
    public $name = '分配';

    public function form()
    {
        $this->text('accepter_phone', '接受者手机号')->rules('required');
    }

    public function handle(Model $model, Request $request)
    {
        // $model ...

        $accepter_phone = $request->get('accepter_phone');

        $model->status = 1;
        $model->accepter_phone = $accepter_phone;
        $model->allot_time = now();
        $model->save();

        return $this->response()->success('Success message.')->refresh();
    }
}
